home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 February: Tool Chest / Dev.CD Feb 94.toast / Tool Chest / Development Platforms / AppsToGo / AppsToGo.src / DTS.Draw / App.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-18  |  6.0 KB  |  219 lines  |  [TEXT/MPS ]

  1. #ifndef __APPHEADER__
  2. #define __APPHEADER__
  3.  
  4. #ifndef __DTSLib__
  5. #include "DTS.Lib.h"
  6. #endif
  7.  
  8. #ifndef __PRINTING__
  9. #include <Printing.h>
  10. #endif
  11.  
  12. #ifndef __TREEOBJ__
  13. #include <TreeObj.h>
  14. #endif
  15.  
  16. /********/
  17.  
  18. #define VH_VERSION  1                /* True means to include ViewHierarchy window.             */
  19. #define DEV_VERSION 1                /* True means allow option-cmd.period escape from dialogs. */
  20.  
  21. /* If you are unfamiliar with programming with the DTS.framework, you probably want to
  22. ** read the file "=How to write your app", which is found at the same level as the
  23. ** directory for this project. */
  24.  
  25. typedef struct {
  26.     DocHeaderInfo    fhInfo;        /* Doc header info (version, print record, window loc. ) */
  27.     TreeObjHndl        root;
  28.                                 /***** Start of custom file info. *****/
  29. } TheDoc;
  30.  
  31. /* Below is the master document structure.  All DTS.framework documents use this structure.
  32. ** For each unique document type, union in a sub-structure for the document-specific
  33. ** information.  In the case of DTS.Chat, there is only one document type.  The structure for
  34. ** this document type is defined just above.  Even though there is only one, it is still
  35. ** placed in a union.  This allows easy addition of additional document types later.
  36. ** Given a FileRec handle called frHndl, a sample dereference to the inBox field would look like:
  37. **     inBox = (*frHndl)->d.doc.inBox;
  38. **
  39. ** The fileState and connect fields are expected and managed by DTS.framework.  Also, the
  40. ** first two fields in the app-specific portion of the document are expected, namely
  41. ** the fhInfo and root fields. */
  42.  
  43. typedef struct FileRec {
  44.     FileStateRec    fileState;        /* DTS.Lib expects this structure here. */
  45.     ConnectRec        connect;        /* DTS.Lib expects this structure here. */
  46.     union {
  47.         TheDoc    doc;                /* Union in each document type here. */
  48.     } d;
  49. } FileRec;
  50.  
  51. /* Below is the definition of the hierarchical document's root object.  If you are using
  52. ** the hierarchical document package TreeObj, then you will need at least this object.
  53. ** TreeObj expects the first two fields to be undo and frHndl, as shown below.  You can
  54. ** add fields after these two fields.  If you use TreeObj, the root object and all of its
  55. ** children are automatically saved and read from disk.
  56. ** Note that the definition for the root object includes a prototype.  Each object is
  57. ** automatically called by DTS.LIB..framework at appropriate times.  The prototype defines the
  58. ** function that will be called for this object.  See the files "=How to write your app"
  59. ** and "=Using TreeObj.c" for more information. */
  60.  
  61. long    TRootObj(TreeObjHndl hndl, short message, long data);
  62. typedef struct {
  63.     TreeObjHndl    undo;        /* This structure may be added to, but */
  64.     FileRecHndl    frHndl;        /* these two first fields must remain. */
  65.     short        numSelected;
  66. } RootObj;
  67.  
  68. /* This definition allows us to access the fields that are in common between the below objects. */
  69.  
  70. typedef struct {
  71.     Boolean        selected;
  72.     Rect        rect;
  73.     short        penHeight;
  74.     short        penWidth;
  75.     RGBColor    borderColor;
  76.     Boolean        content;
  77.     RGBColor    contentColor;
  78. } CommonObj;
  79.  
  80.  
  81. /* Below are the definitions of the various DTS.Draw tool palette objects. */
  82.  
  83. long    TRectObj(TreeObjHndl hndl, short message, long data);
  84. typedef struct {
  85.     Boolean        selected;
  86.     Rect        rect;
  87.     short        penHeight;
  88.     short        penWidth;
  89.     RGBColor    borderColor;
  90.     Boolean        content;
  91.     RGBColor    contentColor;
  92. } RectObj;
  93.  
  94.  
  95. long    TRRectObj(TreeObjHndl hndl, short message, long data);
  96. typedef struct {
  97.     Boolean        selected;
  98.     Rect        rect;
  99.     short        penHeight;
  100.     short        penWidth;
  101.     RGBColor    borderColor;
  102.     Boolean        content;
  103.     RGBColor    contentColor;
  104.     short        width, height;
  105. } RRectObj;
  106.  
  107.  
  108. long    TOvalObj(TreeObjHndl hndl, short message, long data);
  109. typedef struct {
  110.     Boolean        selected;
  111.     Rect        oval;
  112.     short        penHeight;
  113.     short        penWidth;
  114.     RGBColor    borderColor;
  115.     Boolean        content;
  116.     RGBColor    contentColor;
  117. } OvalObj;
  118.  
  119.  
  120. OSErr    CalcPiePoints(TreeObjHndl hndl);
  121. long    TPieObj(TreeObjHndl hndl, short message, long data);
  122. typedef struct {
  123.     Boolean        selected;
  124.     Rect        arc;
  125.     short        penHeight;
  126.     short        penWidth;
  127.     RGBColor    borderColor;
  128.     Boolean        content;
  129.     RGBColor    contentColor;
  130.     short        arcStart;
  131.     short        arcLength;
  132.     Point        center;
  133.     Point        arcBegin;
  134.     Point        arcEnd;
  135. } PieObj;
  136.  
  137.  
  138. long    TLineObj(TreeObjHndl hndl, short message, long data);
  139. typedef struct {
  140.     Boolean        selected;
  141.     Rect        rect;
  142.     short        penHeight;
  143.     short        penWidth;
  144.     RGBColor    borderColor;
  145.     Boolean        content;
  146.     RGBColor    contentColor;
  147.     short        flip;
  148. } LineObj;
  149.  
  150.  
  151. long    TGroupObj(TreeObjHndl hndl, short message, long data);
  152. typedef struct {
  153.     Boolean    selected;
  154.     Rect    group;
  155. } GroupObj;
  156.  
  157.  
  158. long    TExtSelectObj(TreeObjHndl hndl, short message, long data);
  159. typedef struct {
  160.     Boolean    selected;
  161.     Rect    selectArea;
  162. } ExtSelectObj;
  163.  
  164.  
  165. #define VFLIPOBJ 0x01
  166. #define HFLIPOBJ 0x02
  167.  
  168.  
  169. /* Here are some macro definitions to make dereferencing document objects easier. */
  170.  
  171. #define mDerefRoot(hndl)      ((RootObj*)((*hndl) + 1))
  172. #define mDerefCommon(hndl)    ((CommonObj*)((*hndl) + 1))
  173. #define mDerefRect(hndl)      ((RectObj*)((*hndl) + 1))
  174. #define mDerefRRect(hndl)     ((RRectObj*)((*hndl) + 1))
  175. #define mDerefOval(hndl)      ((OvalObj*)((*hndl) + 1))
  176. #define mDerefPie(hndl)       ((PieObj*)((*hndl) + 1))
  177. #define mDerefLine(hndl)      ((LineObj*)((*hndl) + 1))
  178. #define mDerefGroup(hndl)     ((GroupObj*)((*hndl) + 1))
  179. #define mDerefExtSelect(hndl) ((ExtSelectObj*)((*hndl) + 1))
  180.  
  181.  
  182. /********/
  183.  
  184. #define kMaxNumUndos    64
  185. #define kNumSaveUndos    8
  186.  
  187. #define RECTOBJ            16
  188. #define RRECTOBJ        17
  189. #define OVALOBJ            18
  190. #define PIEOBJ            19
  191. #define LINEOBJ            20
  192. #define GROUPOBJ        65
  193. #define EXTSELECTOBJ    66
  194.  
  195. #define kNumTreeObjs    67        /* Minimum number of objects is 16. */
  196.  
  197.  
  198. /********/
  199.  
  200. /* These values are passed to the DTS.LIB..framework function Initialize(). */
  201. #define kMinHeap    64 * 1024        /* Needs at least 64k of heap space. */
  202. #define kMinSpace    64 * 1024        /* Needs this much after calling PurgeSpace. */
  203.  
  204.  
  205. #define kwAppWindow    (kwGrowIcon | kwHScrollLessGrow | kwVScrollLessGrow | kwVisible | kwOpenAtOldLoc)
  206.  
  207. #define kVersion        101        /* Document versions, not application versions. */
  208. #define kMinVersion        100
  209. #define kMaxVersion        101
  210.  
  211. #define kMaxNumWindows        65535        /* No limit on the number of windows. */
  212.  
  213.  
  214. #define kToolHeight 20
  215. #define kNumTools   5
  216.  
  217.  
  218. #endif
  219.